Math

Prograph math primitives use the Apple SANE library of mathematical routines. The integer arithmetic primitives all have names created by doubling the names of the corresponding primitives:  **, ++, --, and ÷÷. They boost performance and therefore should be used instead of their real arithmetic counterparts where possible (for example, when calculating coordinates for graphics).

_________________________________________________
                                             *
 *300*

Input names: Number1; Number2; [Number3;  ...]

Input types: <number>; <number>; [<number>;  ...]

Output names: Product

Output types: <number>

Description: 
Product is the product of Number1, Number2, … .

See also:  +, -, ÷, ++, --, **, ÷÷, +1, -1

_________________________________________________
                                            **
 *300*

Input names: Integer1; Integer2; [Integer3;  ...]

Input types: integer;  integer; [integer;  ...]

Output names: Product

Output types: integer

Description: 
Product is the product of Integer1, Integer2, ….

See also:  +, -, *, ÷, ++, --, ÷÷, +1, -1

_________________________________________________
                                         +
 *301*

Input names: Number1; Number2; [Number3;  ...]

Input types: <number>; <number>; [<number>;  ...]

Output names: Sum

Output types: <number>

Description: 
Sum is the sum of Number1, Number2, ….

See also:   -, *, ÷, ++, --, **, ÷÷, +1, -1

_________________________________________________
                                          ++
 *301*

Input names: Integer1; Integer2; [Integer3;  ...]

Input types: integer; integer; [integer;  ...]

Output names: Sum

Output types: integer

Description: 
Sum is the sum of Integer1, Integer2, ….

See also:  +, -, *, ÷, --, **, ÷÷, +1, -1

_________________________________________________
                            +1
 *301*

Input types: <number>

Output types: <number>

Description: 
Result is Number+1.

See also:  +, -, *, ÷, ++, --, **, ÷÷, -1

_________________________________________________
                                           -
 *302*

Input names: [Number1]; Number2

Input types: [<number>]; <number>

Output names: Result

Output types: <number>

Description: 
Result is Number1 - Number2.

See also:   +, *, ÷, ++, --, **, ÷÷, +1, -1

_________________________________________________
                                          - -
 *302*

Input names: [Integer1]; Integer2

Input types: [integer]; integer

Output names: Result

Output types: integer

Description: 
Result is Integer1 - Integer2.

See also:  +, -, *, ÷, ++, **, ÷÷, +1, -1

_________________________________________________
                       -1
 *302*

Input types: <number>

Output types: <number>

Description: 
Result is Number - 1.

See also:  +, -, *, ÷, ++, --, **, ÷÷, +1

_________________________________________________
                     abs
 *303*

Input types: <number>

Output types: <number>

Description: 
Result is the absolute value of Number.

See also:  sign, sign-extend

_________________________________________________
                       acos
 *303*

Input types: <number>

Output types: <number>

Description: 
Angle is arccosine(Cosine) expressed in radians.

See also:  sin, cos, tan, asin, atan, atan2

_________________________________________________
                           annuity 
 *303*

Input types: <number>;
<number>

Output types: <number>

Description: 
Annuity is (1 - (1 + R)^-N) / R, where R is the interest rate and N is the number of periods.

See also:  compound

_________________________________________________
                         asin
*304*

Input types: <number>

Output types: <number>

Description: 
Angle is arcsine(Sine) expressed in radians.

See also:  sin, cos, tan, acos, atan, atan2

_________________________________________________
                        atan
 *304*

Input types: <number>

Output types: <number>

Description: 
Angle is arctangent(Tangent) expressed in radians.

See also:  sin, cos, tan, asin, acos, atan2

_________________________________________________
                         atan2
 *304*

Input types: <number>; <number>

Output types: <number>

Description: 
Angle is arctangent(Y÷X) expressed in radians.

See also:  sin, cos, tan, asin, acos, atan

_________________________________________________
                                 compound 
 *305*

Input types: <number>; <number>

Output types: <number>

Description: 
Compound is (1 + R )^N where R is the interest rate and N is the number of periods.

See also: 
annuity

_________________________________________________
 
                        cos
 *305*

Input types: <number>

Output types: <number>

Description: 
Cosine is cosine(Angle).

See also:   sin, tan, asin, acos, atan, atan2

_________________________________________________
                                  div
 *305*

Input names: [Dividend];  Divisor

Input types: [<number>];
<number>

Defaults: Dividend = 1

Output names: Quotient

Output types: <number>

Description: 
Quotient is the quotient of Dividend by Divisor. With only one input, Quotient is reciprocal of Divisor.

Alias: ÷

See also:  +, -, *, ++, --, **, ÷÷, idiv, +1, -1

_________________________________________________
                    exp
 *306*

Input types: <number>

Output types: <number>

Description: 
Result is e (1.718281...) to the power of Exponent.

See also:  ln, log10, power, sqrt

_________________________________________________
                                    idiv
 *306*

Input names: [Dividend];  Divisor

Input types: [integer];  integer

Defaults: Dividend = 1

Output names: Quotient;  [Remainder]

Output types: integer;  [integer]

Description: 
Quotient and Remainder are the quotient and remainder of the integer division of Dividend by Divisor.

Alias: ÷÷

See also:  +, -, *, ÷, div, ++, --, **, +1, -1

_________________________________________________
                     ln
 *306*

Input types: <number>

Output types: <number>

Description: 
Log is the natural logarithm (base e) of Number.

See also:  exp, log10, power, sqrt

_________________________________________________
                         log10
 *307*

Input types: <number>

Output types: <number>

Description: 
Log is the logarithm (base 10) of Number.

See also:  exp, ln, power, sqrt

_________________________________________________
                                         max
 *307*

Input names: Number1;
[Number2;  ...]

Input types: <number>;
[<number>;  ...]

Output names: Max

Output types: <number>

Description: 
Max is the maximum of Number1,  ....

See also:  min

_________________________________________________
 
                                     min
 *307*

Input names: Number1;
[Number2;  ...]

Input types: <number>;
[<number>;  ...]

Output names: Min

Output types: <number>

Description: 
Min is the minimum of Number1,  ....

See also: 
max

_________________________________________________
 
                pi
 *308*

Output types: real

Description: 
Pi is the value of pi (3.1415926...).

_________________________________________________
                                       power
 *308*

Input types: <number>;
<number>

Output types: <number>

Description: 
Result is Number to the power of Exponent. If Number and Exponent are both 0, Result is 1.

See also:  exp, ln, log10, sqrt

_________________________________________________
                       rand
 *308*

Output types: integer

Description: 
Returns a random integer between and including 1 and (2**31) - 2.

See also:  set-seed

_________________________________________________
                         round
 *308*

Input types: <number>;  [thePrecision]

Output types: <number>

Description: 
Result is the number closest to Number, according to thePrecision. Positive and negative values for thePrecision indicate the number of decimal places to the right and left of the decimal point, respectively. If thePrecision is not given, or is 0, Result is the integer closest to Number. 

Note: 
If two values are equally near to Number, Round uses the Apple SANE library convention of rounding to the even value. For instance, 12.5 rounds to 12, and 13.5 rounds to 14.

 Rounding to a given number of decimal places does not necessarily mean that the floating point representation of that number has that number of decimal places:  it may have more. The number .95, for example, is actually .9499999999999999999. Use the format primitive to store such numbers as strings with the desired number of decimal places.

See also: 
trunc

_________________________________________________
                                      round-down
*309*

Input types: <number>;  [thePrecision]

Output types: <number>

Description: 
Result is the nearest number less than (or equal to) Number, according to thePrecision. Positive and negative values for thePrecision indicate the number of decimal places to the right and left of the decimal point, respectively. If thePrecision is not given, or is 0, Result is the nearest integer less than (or equal to) Number. 

See also: 
round, round-up, trunc

_________________________________________________
                                round-up
 *309*

Input types: <number>;  [thePrecision]

Output types: <number>

Description: 
Result is the nearest number greater than or equal to Number, according to thePrecision. Positive and negative values for thePrecision indicate the number of decimal places to the right and left of the decimal point, respectively. If thePrecision is not given, or is 0, Result is the nearest integer greater than (or equal to) Number. 

See also: 
round, round-down, trunc

_________________________________________________
                               set-seed
 *310*

Input types: <number>

Description: 
The seed for the random-number generator is set to the integral part of Seed (0 to (2**31) - 1).

See also:  rand

_________________________________________________
 
                         sign
 *310*

Input types: <number>

Output types: integer

Description: 
Sign is 1 if Number is positive, 0 if Number is 0, and -1 otherwise.

See also:  abs, sign-extend

_________________________________________________
                                         sign-extend
 *310*

Input types: integer; integer

Output types: integer

Description: 
If Offset is 1, ValueOut is the integer obtained by propagating the leftmost bit of the rightmost byte of ValueIn through the three left bytes. If Offset is 2, ValueOut is the integer obtained by propagating the leftmost bit of the second least significant byte of ValueIn through the two left bytes.

See also:  abs, sign, get-integer

_________________________________________________
                    sin
 *311*

Input types: <number>

Output types: <number>

Description: 
Sine is sine(Angle).

See also:  cos, tan, asin, acos, atan, atan2

_________________________________________________
                      sqrt
 *311*

Input types: <number>

Output types: <number>

Description: 
Root is the square root of Number.

See also:  exp, ln, log10, power

_________________________________________________
                       tan
 *311*

Input types: <number>

Output types: <number>

Description: 
Tangent is tangent(Angle).

See also:  sin, cos, asin, acos, atan, atan2

_________________________________________________
 
                                     trunc
 *311*

Input types: <number>

Output types: integer | aNumber;  real

Description: 
anInteger and Fraction are the integral and fractional part of Number respectively. The integral part is aNumber if Number is very large.

See also:  round

_________________________________________________
 
                                      ÷
 *312*

Input names: [Dividend];  Divisor

Input types: [<number>];
<number>

Defaults: Dividend = 1

Output names: Quotient

Output types: <number>

Description: 
Quotient is the quotient of Dividend by Divisor. With only one input, Quotient is reciprocal of Divisor.

Alias: div

See also:  +, -, *, ++, --, **, ÷÷, idiv, +1, -1

_________________________________________________
                                         ÷÷
 *312*

Input names: [Dividend];  Divisor

Input types: [integer];  integer

Defaults: Dividend = 1

Output names: Quotient;  [Remainder]

Output types: integer;  [integer]

Description: 
Quotient and Remainder are the quotient and remainder of the integer division of Dividend by Divisor.

Alias: idiv

See also:  +, -, *, ÷, div, ++, --, **, +1, -1